mCurrent Sens Click
mCurrent Sens Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Apr 2026.
- Type : SPI type
Software Support
Example Description
This example demonstrates the use of mCurrent Sens Click for measuring voltage, current, and temperature on two independent channels.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.mCurrentSens
Example Key Functions
- mcurrentsens_cfg_setup This function initializes Click configuration structure to initial values.
void mcurrentsens_cfg_setup(mcurrentsens_cfg_t *cfg)
mCurrent Sens configuration object setup function.
mCurrent Sens Click configuration object.
Definition mcurrentsens.h:436
- mcurrentsens_init This function initializes all necessary pins and peripherals used for this Click board.
err_t mcurrentsens_init(mcurrentsens_t *ctx, mcurrentsens_cfg_t *cfg)
mCurrent Sens initialization function.
mCurrent Sens Click context object.
Definition mcurrentsens.h:411
- mcurrentsens_default_cfg This function executes a default configuration of mCurrent Sens Click board.
err_t mcurrentsens_default_cfg(mcurrentsens_t *ctx)
mCurrent Sens default configuration function.
- mcurrentsens_fetch_calib This function reads calibration values from external EEPROM.
err_t mcurrentsens_fetch_calib(mcurrentsens_t *ctx)
mCurrent Sens fetch calibration function.
- mcurrentsens_read_ch1_current This function reads channel 1 current measurement in mA.
err_t mcurrentsens_read_ch1_current(mcurrentsens_t *ctx, float *data_out)
mCurrent Sens read channel 1 current function.
- mcurrentsens_read_ch1_voltage This function reads channel 1 voltage measurement in mV.
err_t mcurrentsens_read_ch1_voltage(mcurrentsens_t *ctx, float *data_out)
mCurrent Sens read channel 1 voltage function.
Application Init
Initializes communication, configures the device, optionally performs calibration, and loads calibration data from EEPROM. ADC oversampling ratio is set for faster runtime measurements.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
#if ENABLE_CALIBRATION
{
log_printf( &logger, " Device calibration success\r\n" );
}
else
{
log_error( &logger, " Device calibration" );
for ( ; ; );
}
#endif
{
log_printf( &logger, " Calibration data read from EEPROM\r\n" );
}
else
{
log_error( &logger, " Calibration fetch - No communication with EEPROM or EEPROM is empty" );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define MCURRENTSENS_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition mcurrentsens.h:382
#define MCURRENTSENS_CONFIG1_OSR_256
Definition mcurrentsens.h:158
err_t mcurrentsens_set_osr(mcurrentsens_t *ctx, uint8_t osr)
mCurrent Sens set OSR function.
void application_init(void)
Definition main.c:59
#define MIKROBUS_POSITION_MCURRENTSENS
Definition main.c:28
@ MCURRENTSENS_OK
Definition mcurrentsens.h:464
@ MCURRENTSENS_ERROR
Definition mcurrentsens.h:465
Application Task
Reads and logs voltage, current, and temperature values continuously.
{
float ch1_voltage_mv = 0;
float ch1_current_ma = 0;
float ch2_voltage_mv = 0;
float ch2_current_ma = 0;
float temperature = 0;
{
log_printf( &logger, " CH1 voltage : %.1f mV\r\n", ch1_voltage_mv );
}
else
{
log_printf( &logger, " CH1 voltage read error\r\n" );
}
{
log_printf( &logger, " CH1 current : %.2f mA\r\n", ch1_current_ma );
}
else
{
log_printf( &logger, " CH1 current read error\r\n" );
}
{
log_printf( &logger, " CH2 voltage : %.1f mV\r\n", ch2_voltage_mv );
}
else
{
log_printf( &logger, " CH2 voltage read error\r\n" );
}
{
log_printf( &logger, " CH2 current : %.2f mA\r\n", ch2_current_ma );
}
else
{
log_printf( &logger, " CH2 current read error\r\n" );
}
{
log_printf( &logger, " Temperature : %.2f degC\r\n", temperature );
}
else
{
log_printf( &logger, " Temperature read error\r\n" );
}
log_printf( &logger, "-----------------------------\r\n" );
Delay_ms( 1000 );
}
err_t mcurrentsens_read_temperature(mcurrentsens_t *ctx, float *data_out)
mCurrent Sens read temperature function.
err_t mcurrentsens_read_ch2_current(mcurrentsens_t *ctx, float *data_out)
mCurrent Sens read channel 2 current function.
err_t mcurrentsens_read_ch2_voltage(mcurrentsens_t *ctx, float *data_out)
mCurrent Sens read channel 2 voltage function.
void application_task(void)
Definition main.c:120
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.